home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / VISUALBA / SCROLVB.ZIP / SCROLL-1.FRM < prev    next >
Text File  |  1994-02-01  |  9KB  |  303 lines

  1. VERSION 2.00
  2. Begin Form frmMain 
  3.    Caption         =   "Scroll-1 Demo"
  4.    Height          =   3180
  5.    Icon            =   SCROLL-1.FRX:0000
  6.    Left            =   1650
  7.    LinkTopic       =   "Form1"
  8.    ScaleHeight     =   185
  9.    ScaleMode       =   3  'Pixel
  10.    ScaleWidth      =   249
  11.    Top             =   1500
  12.    Width           =   3855
  13.    Begin PictureBox picCorner 
  14.       BackColor       =   &H00C0C0C0&
  15.       Height          =   255
  16.       Left            =   120
  17.       ScaleHeight     =   225
  18.       ScaleWidth      =   225
  19.       TabIndex        =   3
  20.       Top             =   120
  21.       Width           =   255
  22.    End
  23.    Begin CommandButton cmdStart 
  24.       Caption         =   "&Start"
  25.       Height          =   375
  26.       Left            =   2040
  27.       TabIndex        =   0
  28.       Top             =   120
  29.       Width           =   1575
  30.    End
  31.    Begin VScrollBar vsb1 
  32.       Height          =   1455
  33.       LargeChange     =   50
  34.       Left            =   120
  35.       SmallChange     =   10
  36.       TabIndex        =   2
  37.       Top             =   480
  38.       Width           =   255
  39.    End
  40.    Begin HScrollBar hsb1 
  41.       Height          =   255
  42.       LargeChange     =   50
  43.       Left            =   480
  44.       SmallChange     =   10
  45.       TabIndex        =   1
  46.       Top             =   120
  47.       Width           =   1455
  48.    End
  49.    Begin PictureBox picBig 
  50.       BackColor       =   &H00FFFF00&
  51.       BorderStyle     =   0  'None
  52.       Height          =   2055
  53.       Left            =   480
  54.       ScaleHeight     =   137
  55.       ScaleMode       =   3  'Pixel
  56.       ScaleWidth      =   209
  57.       TabIndex        =   4
  58.       Top             =   600
  59.       Width           =   3135
  60.       Begin CommandButton cmdExit 
  61.          Caption         =   "E&xit"
  62.          Height          =   375
  63.          Index           =   0
  64.          Left            =   120
  65.          TabIndex        =   9
  66.          Top             =   1560
  67.          Width           =   2895
  68.       End
  69.       Begin Label lblDownRight 
  70.          Alignment       =   2  'Center
  71.          BorderStyle     =   1  'Fixed Single
  72.          Caption         =   "to the four corners!"
  73.          Height          =   255
  74.          Left            =   120
  75.          TabIndex        =   8
  76.          Top             =   1200
  77.          Width           =   2895
  78.       End
  79.       Begin Label lblDownLeft 
  80.          Alignment       =   2  'Center
  81.          BorderStyle     =   1  'Fixed Single
  82.          Caption         =   "and these labels will be moved"
  83.          Height          =   255
  84.          Left            =   120
  85.          TabIndex        =   7
  86.          Top             =   840
  87.          Width           =   2895
  88.       End
  89.       Begin Label lblUpRight 
  90.          Alignment       =   2  'Center
  91.          BorderStyle     =   1  'Fixed Single
  92.          Caption         =   "the picture box will be enlarged,"
  93.          Height          =   255
  94.          Left            =   120
  95.          TabIndex        =   6
  96.          Top             =   480
  97.          Width           =   2895
  98.       End
  99.       Begin Label lblUpLeft 
  100.          Alignment       =   2  'Center
  101.          BorderStyle     =   1  'Fixed Single
  102.          Caption         =   "When you click ""Start"","
  103.          Height          =   255
  104.          Left            =   120
  105.          TabIndex        =   5
  106.          Top             =   120
  107.          Width           =   2895
  108.       End
  109.    End
  110. End
  111.  
  112. ' SCROLL-1.FRM - Declarations.
  113.  
  114.     DefInt A-Z
  115.  
  116. ' End Of Declarations.
  117.  
  118. Sub cmdExit_Click (Index As Integer)
  119.  
  120. ' Completely self explanatory!
  121.  
  122.     End
  123.  
  124. End Sub
  125.  
  126. Sub cmdStart_Click ()
  127.  
  128. ' Hide the Start button right away.
  129.  
  130.     cmdStart.Visible = False
  131.  
  132. ' Move and enlarge the scrolling picture box.
  133. '
  134. ' The "600, 400" can be changed to any reasonable size,
  135. ' up to a maximum of 16,383 by 16,383 pixels.
  136. '
  137. ' If AutoRedraw=True then larger sizes use a _LOT_ more memory.
  138.  
  139.     picBig.Move 0, 0, 600, 400
  140.  
  141. ' Move the four labels out to the corners of picBig. These are not critical,
  142. ' and they aren't necessary for scrolling the picBig box.
  143.  
  144.     lblUpLeft.Move 0, 0
  145.     lblUpRight.Move (picBig.Width - lblUpRight.Width), 0
  146.     lblDownLeft.Move 0, (picBig.Height - lblDownLeft.Height)
  147.  
  148.     temp1 = picBig.Width - lblUpRight.Width
  149.     temp2 = picBig.Height - lblDownLeft.Height
  150.     lblDownRight.Move temp1, temp2
  151.  
  152. ' Now duplicate the "Exit" command button a few times, just to have some
  153. ' other sample controls on the form. These are not critical, and can be
  154. ' removed and replaced with any other kind of control.
  155.  
  156.     For temp = 1 To 7
  157.     Load cmdExit(temp)
  158.     Next temp
  159.  
  160. ' Organize the little Exit buttons - just to have something else to scroll.
  161. ' The following code is NOT critical, and isn't necessary for scrolling the
  162. ' picBig box. You would normally put more MEANINGFUL controls onto the box,
  163. ' for example: Text boxes, command buttons, picture boxes, labels, option
  164. ' buttons, just about anything!
  165.  
  166.     For x = 0 To 7
  167.     cmdExit(x).Move 75 + (x * 50), 50 + (x * 40), 100, 20
  168.     cmdExit(x).Visible = True
  169.     Next x
  170.  
  171. ' Move the scroll bars to their correct locations.
  172.  
  173.     Call FixScrollBars
  174.  
  175. End Sub
  176.  
  177. Sub FixScrollBars ()
  178.  
  179. ' Assume you won't need to display anything.
  180.  
  181.     vertFLAG = False
  182.     horizFLAG = False
  183.     cornerFLAG = False
  184.  
  185. ' Figure out how much WIDTH of the picture box is hidden now,
  186. ' and if any width is hidden, you need a horizontal scroll bar.
  187.  
  188.     HiddenX = (picBig.Width) - (frmMain.ScaleWidth)
  189.     If HiddenX > 0 Then horizFLAG = True
  190.  
  191. ' Figure out how much HEIGHT of the picture box is hidden now,
  192. ' and if any height is hidden, you need a vertical scroll bar.
  193.  
  194.     HiddenY = (picBig.Height) - (frmMain.ScaleHeight)
  195.     If HiddenY > 0 Then vertFLAG = True
  196.  
  197. ' If horizontal scroll bar is ON, then slightly less height is available,
  198. ' so re-check the height.
  199.  
  200.     If horizFLAG = True Then
  201.     HiddenY = (picBig.Height - 1) - (frmMain.ScaleHeight - hsb1.Height)
  202.     If HiddenY > 0 Then vertFLAG = True
  203.     End If
  204.  
  205. ' If vertical scroll bar is ON, then slightly less width is available,
  206. ' so re-check the width.
  207.     
  208.     If vertFLAG = True Then
  209.     HiddenX = (picBig.Width - 1) - (frmMain.ScaleWidth - vsb1.Width)
  210.     If HiddenX > 0 Then horizFLAG = True
  211.     End If
  212.  
  213. ' If both scroll bars are ON, then turn on the corner box.
  214.  
  215.     If (horizFLAG = True) And (vertFLAG = True) Then cornerFLAG = True
  216.  
  217. ' At this point, you know if hsb1/vsb1/picCorner will be ON or OFF,
  218. ' so if anything will be OFF, make it invisible now. This section doesn't
  219. ' make anything visible, because if something is invisible, it's better
  220. ' to leave it that way until AFTER it is moved.
  221.  
  222.     If horizFLAG = False Then hsb1.Visible = False
  223.     If vertFLAG = False Then vsb1.Visible = False
  224.     If cornerFLAG = False Then picCorner.Visible = False
  225.  
  226. ' Move the vertical scroll bar over to the right side of the form,
  227. ' and make sure it's visible.
  228.  
  229.     If vertFLAG = True Then
  230.     ' Top is always 0.
  231.         vsb1.Top = 0
  232.     ' Find the new height - but watch out for negative numbers.
  233.         tempVH = frmMain.ScaleHeight - hsb1.Height + 2
  234.         If horizFLAG = False Then tempVH = frmMain.ScaleHeight + 1
  235.         If tempVH > 0 Then vsb1.Height = tempVH
  236.     ' Find the new left - but watch out for negative numbers.
  237.         tempVL = frmMain.ScaleWidth - vsb1.Width + 1
  238.         If tempVL > 0 Then vsb1.Left = tempVL
  239.     ' Show it.
  240.         vsb1.Visible = True
  241.     End If
  242.  
  243. ' Move the horizontal scroll bar down to the bottom of the form,
  244. ' and make sure it's visible.
  245.  
  246.     If horizFLAG = True Then
  247.     ' Left is always 0.
  248.         hsb1.Left = 0
  249.     ' Find the new width - but watch out for negative numbers.
  250.         tempHW = frmMain.ScaleWidth - vsb1.Width + 2
  251.         If vertFLAG = False Then tempHW = frmMain.ScaleWidth + 1
  252.         If tempHW > 0 Then hsb1.Width = tempHW
  253.     ' Find the new top - but watch out for negative numbers.
  254.         tempHT = frmMain.ScaleHeight - hsb1.Height + 1
  255.         If tempHT > 0 Then hsb1.Top = tempHT
  256.     ' Show it.
  257.         hsb1.Visible = True
  258.     End If
  259.  
  260. ' Move the little grey corner box to the lower right corner of the form.
  261. '